package client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

public class ClientTcpReceiverThread implements Runnable {

	private boolean isRunning = true;
	private Socket socket;

	public boolean isRunning() {
		return isRunning;
	}

	public void setRunning(boolean isRunning) {
		this.isRunning = isRunning;
	}
	
	public ClientTcpReceiverThread(Socket socket) {
		this.socket = socket;
	}
	
	@Override
	public void run() {
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(
					socket.getInputStream()));
			String fromServer;
			while (isRunning) {
				fromServer = in.readLine();
				if (fromServer.contains("|")) {
					System.out.println(fromServer.replace("|", "\r\n"));
				} else {
					System.out.println(fromServer);
				}
			}
			
			in.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
